<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>shopCart-<?php echo ($tpshop_config['shop_info_store_title']); ?></title>
<meta http-equiv="keywords" content="<?php echo ($tpshop_config['shop_info_store_keyword']); ?>" />
<meta name="description" content="<?php echo ($tpshop_config['shop_info_store_desc']); ?>" />
<script src="/Public/js/jquery-1.8.2.min.js"></script>
<script src="/Public/js/global.js"></script>
<script src="/Public/js/pc_common.js"></script>
<script src="/Public/js/layer/layer.js"></script><!--弹窗js 参考文档 http://layer.layui.com/-->
    <link rel="stylesheet" href="/Public/Static/css/index.css" type="text/css">
</head>

<body>
    <link rel="stylesheet" href="/Public/Static/css/index.css" type="text/css">

<link href="/Public/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
<link href="/Public/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="/Public/images1/ICONlogo.png" type="image/x-icon"/>
<link href="/Public/basic/css/demo.css" rel="stylesheet" type="text/css" />

<link href="/Public/css1/hmstyle.css" rel="stylesheet" type="text/css"/>
<link href="/Public/css1/skin.css" rel="stylesheet" type="text/css" />
<script src="/Public/AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
<script src="/Public/AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>
<div class="am-container header">
    <ul class="message-l">
        <div class="topMessage">
            <div class="menu-hd">
                <a href="<?php echo U('Home/User/login');?>" target="_top" class="h" style="border-right: 1px solid #000">Sign in&nbsp;</a>
                <a href="<?php echo U('Home/User/register');?>" target="_top">Join</a>
            </div>
        </div>
    </ul>
    <ul class="message-r">
        <div class="topMessage home">
            <div class="menu-hd"><a href="<?php echo U('Home/Index/index');?>" target="_top" class="h"><span>INDEX</span></a></div>
        </div>
        <div class="topMessage my-shangcheng">
            <div class="menu-hd MyShangcheng"><a href="<?php echo U('Home/User/index');?>" target="_top"><img src="/Public/images1/user.png"  alt=""><span>Personal center</span></a></div>
        </div>
        <div class="topMessage mini-cart">
            <div class="menu-hd"><a id="mc-menu-hd" href="<?php echo U('Home/Cart/cart');?>" target="_top"><img src="/Public/images1/shop.png" alt=""><span>Shopping cart</span><strong id="J_MiniCartNum" class="h">0</strong></a></div>
        </div>
        <div class="topMessage favorite">
            <div class="menu-hd"><a href="#" target="_top"><img src="/Public/images1/love.png" width="24" alt=""><span>Favorite</span></a></div>
        </div>
        <div class="topMessage favorite">
            <div class="menu-hd"><a href="<?php echo U('Home/User/logout');?>" target="_top"><img src="/Public/images1/love.png" width="24" alt=""><span>Logout</span></a></div>
        </div>
    </ul>
</div>

    <div class="order-header">
    	<div class="layout after">
        	<div class="fl">
            	<div class="logo pa-to-36 wi345">
                	<a href="/"><img src="<?php echo ($tpshop_config['shop_info_store_logo']); ?>" alt=""></a>
                </div>
            </div>
        	<div class="fr">
            	<div class="pa-to-36 progress-area">
                	<div class="progress-area-wd">我的购物车1</div>
                	<div class="progress-area-tx" style="display:none">填写核对订单信息</div>
                	<div class="progress-area-cg" style="display:none">成功提交订单</div>
                </div>
            </div>
        </div>
    </div>
    <div class="layout after-ta">
    	<div class="sc-list">        
        <form name="cart_form" id="cart_form" action="<?php echo U('Home/Cart/ajaxCartList');?>">
	         <div id="ajax_return"><!--  ajax renturn --></div>
         </form>         
            <div class="sc-acti-list ma-to-20 ma-bo-135">
            	<a class="gwc-jxgw" href="/">To continue shopping</a>
                <a class="gwc-qjs" href="<?php echo U('Home/Cart/cart2');?>" >To settle accounts</a>
            </div>
        </div>
    </div>
<!--------footer-开始-------------->
<div class="footer ">
    <div class="footer-bd ">
        <p>China Contact: Ms.Sophia Gan EMAIL:sophia@sensilintl.com Tel: 0086 15880683346</p>
        <p>USA Contact: Mr.Brian Williams EMAIL:brain@sensilintl.com
            Tel:001 702 308 4860 M: 001 660537 2111 /001 619 5724642</p>
        <p>© 2017-2018 Sensil International INC.</p>
    </div>
</div>

<!--------footer-结束-------------->
<script>

$(document).ready(function(){
			
	ajax_cart_list(); // ajax 请求获取购物车列表
});



// ajax 提交购物车
var before_request = 1; // 上一次请求是否已经有返回来, 有才可以进行下一次请求
function ajax_cart_list(){
	
	
	if(before_request == 0) // 上一次请求没回来 不进行下一次请求
	    return false;
	before_request = 0;
		
	$.ajax({
		type : "POST",
		url:"<?php echo U('Home/Cart/ajaxCartList');?>",//+tab,
		data : $('#cart_form').serialize(),// 你的formid
		success: function(data){
			$("#ajax_return").html('');
			$("#ajax_return").append(data);
			before_request = 1;
		}
	});
}

/**
* 购买商品数量加加减减
* 购买数量 , 购物车id , 库存数量
*/
function switch_num(num,cart_id,store_count)
{
	var num2 = parseInt($("input[name='goods_num["+cart_id+"]']").val());
	num2 += num;
	if(num2 < 1) num2 = 1; // 保证购买数量不能少于 1
	if(num2 > store_count) 
	{   
	    error = "库存只有 "+store_count+" 件, 你只能买 "+store_count+" 件";
	    layer.alert(error, {icon: 2});	
		num2 = store_count; // 保证购买数量不能多余库存数量		
	}

	$("input[name='goods_num["+cart_id+"]']").val(num2);

	ajax_cart_list(); // ajax 更新商品价格 和数量
}


/**  全选 反选 **/				
function check_all()
{	   
	var vt = $("#select_all").is(':checked');
	$("input[name^='cart_select']").prop('checked',vt);
	// var checked = !$('#select_all').attr('checked');
	// $("input[name^='cart_select']").attr("checked",!checked); 		 	
	 ajax_cart_list(); // ajax 更新商品价格 和数量		
}
 
 
// ajax 删除购物车的商品
function ajax_del_cart(ids)
{
	$.ajax({
		type : "POST",
		url:"<?php echo U('Home/Cart/ajaxDelCart');?>",//+tab,
		data:{ids:ids}, // 
	    dataType:'json',		
		success: function(data){
		  // alert(data.msg);
		   if(data.status == 1)				
				ajax_cart_list(); // ajax 请求获取购物车列表		   			   
		}
	});
}

// 批量删除购物车的商品
function del_cart_more()
{
	if(!confirm('Sure you want to delete ?'))
	  return false;
	// 循环获取复选框选中的值  
	var chk_value = [];
	$('input[name^="cart_select"]:checked').each(function(){
		var s_name = $(this).attr('name');
		var id = s_name.replace('cart_select[','').replace(']','');		
		chk_value.push(id);
	}); 
	// ajax  调用删除
	if(chk_value.length > 0)
		ajax_del_cart(chk_value.join(','));
}
</script>
</body>
</html>